package cloud.maque.module.system.controller;

import cloud.maque.common.core.response.R;
import cloud.maque.module.system.entity.SysDept;
import cloud.maque.module.system.entity.SysPost;
import cloud.maque.module.system.extend.DeptExtendService;
import cloud.maque.module.system.model.DeptDto;
import cloud.maque.module.system.service.DeptService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 岗位
 */
@Tag(name = "部门接口")
@RestController
@RequestMapping(value = "/dept")
public class DeptController {


    @Autowired
    DeptService deptService;

    @Autowired
    DeptExtendService extendService;

    @Operation(summary = "部门查询列表")
    @PostMapping("/list")
    public R<List<DeptDto>> List(@RequestBody SysDept pageReq) {
        return R.ok("OK", extendService.GetDeptList(pageReq));
    }

    @Operation(summary = "部门保存")
    @PostMapping("/save")
    public R<SysDept> Save(@RequestBody SysDept data) {

        return R.ok("OK", deptService.SaveDept(data));
    }

    @Operation(summary = "部门状态修改")
    @PostMapping("/edit-status")
    public R<SysPost> EditStatus(@RequestBody SysDept data) {
        return R.ok("OK", deptService.EditStatus(data));
    }


    @Operation(summary = "部门删除,逻辑删除")
    @DeleteMapping("/delete/{id}")
    public R<Boolean> Delete(@PathVariable("id") String id) {
        return R.ok("OK", deptService.DeleteDept(id));
    }
}
